IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spPrintQueue_RetrieveAll')
	BEGIN
		PRINT 'Dropping Procedure spPrintQueue_RetrieveAll'
		DROP  Procedure  spPrintQueue_RetrieveAll
	END

GO

PRINT 'Creating Procedure spPrintQueue_RetrieveAll'
GO

CREATE Procedure spPrintQueue_RetrieveAll
	(
		@PrintQueue_ID int = null, 
		@FileName varchar(50) = null, 
		@FilePath varchar(50) = null, 
		@UserName varchar(50) = null, 
		@PrinterName varchar(50) = null, 
		@PrinterFileName varchar(50) = null, 
		@PrintCopies int = null, 
		@Date DateTime = null, 
		@Printed numeric = null, 
		@PrintedDate DateTime = null
	)
AS
    /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 10/4/2007	Initial version created
    ------------------------------------------------------------------------------
    */
	
	SET NOCOUNT ON
	
	-- Retrieve the relevant records
	SELECT  *
	FROM	PrintQueue
	
	WHERE	(@PrintQueue_ID IS NULL OR PrintQueue.PrintQueue_ID = @PrintQueue_ID)
	  AND	(@FileName IS NULL OR PrintQueue.FileName LIKE @FileName + '%')
	  AND	(@FilePath IS NULL OR PrintQueue.FilePath LIKE @FilePath + '%')
	  AND	(@UserName IS NULL OR PrintQueue.UserName LIKE @UserName + '%')
	  AND	(@PrinterName IS NULL OR PrintQueue.PrinterName LIKE @PrinterName + '%')
	  AND	(@PrinterFileName IS NULL OR PrintQueue.PrinterFileName LIKE @PrinterFileName + '%')
	  AND	(@PrintCopies IS NULL OR PrintQueue.PrintCopies = @PrintCopies)
	  AND	(@Date IS NULL OR PrintQueue.Date = @Date)
	  AND	(@Printed IS NULL OR PrintQueue.Printed = @Printed)
	  AND	(@PrintedDate IS NULL OR PrintQueue.PrintedDate = @PrintedDate)

	-- Return to calling method
	RETURN
GO
